<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * 技术员管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array('type'=>1);
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$params['uniacid']=$_SESSION['uniacid'];
	$params['store_id']=$store_id;
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 30;
	$total='';
	$list=pdo_getslice('jy_wxshifu_member',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['member']=cfc('core')->member_show($item['mid']);
		$item['areatitle']=pdo_getcolumn('jy_wxshifu_area',array('id'=>$item['group_id'],'uniacid'=>$_SESSION['uniacid']),'title');
		$item['ordernum']=pdo_count('jy_wxshifu_order',array('shifuid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
		$item['starnum']=pdo_count('jy_wxshifu_comments',array('shifuid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
		$item['starall']=pdo_get('jy_wxshifu_comments',array('shifuid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']),'star');
		if($item['starnum']){
			$item['star']=$item['starall']/$item['starnum'];
		}
		$item['stargood']=pdo_count('jy_wxshifu_comments',array('star >='=>4,'shifuid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
		if($item['starall']){
			$item['goodstar']=$item['stargood']*100/$item['starall'];
		}
		$item['rank']=$this->model('member')->getrank($item['star'],$item['ordernum']);
	}
	paixu($list,'rank','desc');
	foreach($list as $k=>&$lv){
		$rank=$k+1;
		$lv['ranktitle']='第'.$rank.'名';
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'技术员数据分析'),
		),
		'list'=>array('data'=>'list','tip'=>'[温馨提示]：这里是技术员管理数据分析报表主要体现业绩和评价分！
		','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
			array('name'=>'ranktitle','title'=>'排名','type'=>'string'),
			array('name'=>'title','title'=>'技术员姓名','type'=>'string'),
			array('name'=>'areatitle','title'=>'服务点','type'=>'string'),
			array('name'=>'ordernum','title'=>'单量','type'=>'string'),
			array('name'=>'star','title'=>'评分','type'=>'string'),
			array('name'=>'goodstar','title'=>'好评率','type'=>'string'),
		)),
		'search_one'=>array('name'=>'title'),
	);
	$return['htmls']=$htmls;
	exi($return);
}